package com.hzhr.iot.collect.service.helper;

import com.hzhr.iot.collect.Global;
import com.hzhr.iot.core.exception.ServiceException;
import com.hzhr.iot.device.sdk.model.iotDevice_currentMessageId.IotDevice_CurrentMessageIdModel;
import com.hzhr.iot.device.sdk.service.Device_IotDevice_CurrentMessageIdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.Map;

@Component
public class Device_IotDevice_CurrentMessageIdServiceHelper {
    @Autowired
    Device_IotDevice_CurrentMessageIdService device_iotDevice_currentMessageIdService;
    @Autowired
    Global global;

    public IotDevice_CurrentMessageIdModel getByIotDeviceId(String iotPlatformDeviceId) throws ServiceException {
        if (StringUtils.isEmpty(iotPlatformDeviceId)) return null;
        Map<String, Object> query = new HashMap<>();
        query.put("_show", "one");
        IotDevice_CurrentMessageIdModel result = device_iotDevice_currentMessageIdService.getByIotDeviceId(
                global.initGlobalHeader(), Integer.parseInt(iotPlatformDeviceId), query).getModel();
        return result;
    }

}
